//
//  String+Extension.swift
//  Ccweibo
//
//  Created by 陈锦聪 on 16/3/30.
//  Copyright © 2016年 Coco. All rights reserved.
//

import Foundation

extension String {
    
    var sourceString: String {
        get {
            let pattern = ">(.*?)<"
            let regular = try! NSRegularExpression(pattern: pattern, options: NSRegularExpressionOptions.DotMatchesLineSeparators)
            let result = regular.firstMatchInString(self, options: NSMatchingOptions(rawValue: 0), range: NSRange(location: 0, length: self.characters.count))
            guard let temp = result else {
                return "未知来源"
            }
            let range = temp.rangeAtIndex(1)
            return (self as NSString).substringWithRange(range)
        }
    }
}